package org.yjc.service;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yjc.entity.Grade;
import org.yjc.repository.GradeRepository;

@Service
public class GradeService {
	@Autowired
	private GradeRepository gradeDAO;

	public Grade findByStudentIdAndCourseId(Integer xsid, Integer kcid) {
		return gradeDAO.findByStudentIdAndCourseId(xsid,kcid);
	}

	public void save(Grade cj) {
		gradeDAO.save(cj);
	}

	public List<Grade> findByStudentTbClassIdAndCourseId(Integer tbclassid, Integer courseid) {
		return gradeDAO.findByStudentTbClassIdAndCourseId(tbclassid,courseid);
	}

	public Grade findById(Integer id) {
		Optional<Grade> optional = gradeDAO.findById(id);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}
}
